<template>
	<view class="tbody">
		<u-search placeholder="输入委员姓名或职位进行查找" v-model="keyword" @custom="custom"></u-search>
		<view class="message" v-for="(item,index) in data" :key="index">
			<view class="distinction">
				{{item.communicationType}}
			</view>
			<view class="my-message" v-for="(x,y) in item.userDtoList" :key="y" >
				<image :src="URL + x.avatar" mode="" class="image"></image>
				<view class="my-message-right">
					<view class="one">
						<text class="sty">姓名：</text><text>{{x.realName}}</text>
					</view>
					<view class="two">
						<text class="sty">职务：</text><text style="width: 410rpx;display: inline-block;">{{x.duty}}</text>
					</view>
					<view class="three">
						<text class="sty">手机：</text><text style="margin-right: 100rpx;">{{x.phonenumber}}</text>
						<u-icon  name="phone-fill" color="#16c1db" size="20" @click="tel(x.phonenumber)"></u-icon>
						
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				URL: this.$store.state.user.URL,
					keyword:'',
				data: []
			};
		},
		onShow() {
			this.getcommitteeMember()
		},
		methods: {
			// 拨打电话
			tel(phone) {
			  wx.makePhoneCall({
			    phoneNumber: phone, //要拨打的电话号码 。
			    success: function () {
			      console.log("拨打电话成功！")
			    },
			    fail: function () {
			      console.log("拨打电话失败！")
			    }
						
			  })
						
			},
			async custom() {
				setTimeout(async() => {
					const res = await uni.$http.post(`/business/user/find?keyword=${this.keyword}`)	
					// const res = await uni.$http.get(`/business/user/find?params=${this.keyword}`)
					this.data = res.data
				}, 1000)


			},
			// 获取委员信息
			async getcommitteeMember() {
				const res = await uni.$http.get('/business/user')
				this.data = res.data
			}
		}
	}
</script>

<style lang="scss">
	.message {
		margin-top: 60rpx;

		.distinction {
			font-size: 32rpx;
			font-weight: 700;
			letter-spacing: 0px;
			line-height: 0px;
			color: rgba(20, 58, 64, 1);
			margin-bottom: 48rpx;
		}

		.my-message {
			box-sizing: border-box;
			// margin-top: 48rpx;
			padding: 24rpx;
			opacity: 1;
			border-radius: 20rpx;
			background: #f5fdff;
			box-shadow: 0px 0px 8rpx 0px rgba(22, 193, 219, 0.1);
			display: flex;
			justify-content: flex-start;

			.image {
				width: 144rpx;
				height: 188rpx;
				opacity: 1;
				border-radius: 16rpx;
				margin-right: 24rpx;
			}

			.my-message-right {
				position: relative;
				width: 510rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: rgba(51, 59, 106, 1);

				text {
					margin-bottom: 16rpx;
				}

				.three {
					position: absolute;
					top: 160rpx;
					display: flex;
				}

				.two {
					display: flex;
				}

				.sty {
					width: 72rpx;
					font-size: 24rpx;
					font-weight: 700;
					color: rgba(20, 58, 64, 1);
				}
			}
		}
	}
</style>